package com.lyx.controller;


import com.lyx.entity.Department;
import com.lyx.entity.User;
import com.lyx.response.Result;
import com.lyx.service.DepartmentService;
import com.lyx.vo.DepartmentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author com.lyx
 * @since 2022-03-02
 */
@Api(tags = "部门控制器")
@CrossOrigin

@RestController
@RequestMapping("/department")
public class DepartmentController {
    @Autowired
    DepartmentService departmentService;

    @ApiOperation(value = "查询所有部门1")
    @GetMapping("/getDepartment")
    public Result getUserList(){
        List<Department> department = departmentService.list();
        return  Result.ok().data("department",department);

    }

    @ApiOperation(value = "查询所有部门2")
    @GetMapping("/findAll")
    public Result findAll(){
        List<DepartmentVO> departmentList = departmentService.findDeptAndCount();
        return  Result.ok().data("departmentList",departmentList);
    }
}

